package com.chinasofti.myjdk8date.mydate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class JKD8DateDemo1 {
    public static void main(String[] args) throws ParseException {
        //JDKMthod();
        String s = "2023年04月13日 10:54:00";
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        LocalDateTime localDateTime = LocalDateTime.parse(s, pattern);
        LocalDateTime newlocalDateTime = localDateTime.plusDays(2);
        String result = newlocalDateTime.format(pattern);
        System.out.println(result);
    }

    private static void JDKMthod() throws ParseException {
        String s = "2023年04月13日 10:54:00";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        Date date = sdf.parse(s);
        long time = date.getTime();
        time  = time + (1000 * 60 * 60 * 24);

        Date newDate = new Date(time);
        String result = sdf.format(newDate);
        System.out.println("result = " + result);
    }
}